#include "FunctionProperty.h"

CFunctionProperty::CFunctionProperty(
    CPropertyList *InParentList
    , TMap<EPropertyFlags, SReflectionMetaDataValue> InMetaData
    , std::function<CAny(const void *)> InGetterFunction
    , std::function<void(void *, const CAny &)> InSetterFunction
    , const SDecoratedType& InType
    , CString InName
    )
    : CProperty(InParentList,InName , InType, InMetaData)
{
    GetterFunction = InGetterFunction;
    SetterFunction = InSetterFunction;

    NonStaticProperty = new CFunctionPropertyGetSet(this);
}

CFunctionPropertyGetSet::CFunctionPropertyGetSet(CFunctionProperty *InProperty)
{
    Property = InProperty;
}

CAny CFunctionPropertyGetSet::GetValue(const void *InObjectPtr)
{
    return Property->GetterFunction(InObjectPtr);
}

void CFunctionPropertyGetSet::SetValue(void *InObjectPtr, const CAny &InValue)
{
    Property->SetterFunction(InObjectPtr, InValue);
}
